home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.UserControl DJIp
- Appearance = 0 'Flat
- BackColor = &H80000005&
- BorderStyle = 1 'Fixed Single
- ClientHeight = 465
- ClientLeft = 0
- ClientTop = 0
- ClientWidth = 2070
- LockControls = -1 'True
- ScaleHeight = 465
- ScaleWidth = 2070
- ToolboxBitmap = "DJIp.ctx":0000
- Begin VB.Frame Frame1
- Appearance = 0 'Flat
- BackColor = &H80000005&
- BorderStyle = 0 'None
- Caption = "Frame1"
- ForeColor = &H80000008&
- Height = 240
- Left = 50
- TabIndex = 0
- Top = 50
- Width = 1845
- Begin VB.TextBox txtOctet
- Alignment = 2 'Center
- Appearance = 0 'Flat
- BorderStyle = 0 'None
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 240
- Index = 1
- Left = 15
- TabIndex = 1
- Text = "255"
- Top = 0
- Width = 375
- End
- Begin VB.TextBox txtOctet
- Alignment = 2 'Center
- Appearance = 0 'Flat
- BorderStyle = 0 'None
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 240
- Index = 2
- Left = 495
- TabIndex = 2
- Text = "255"
- Top = 0
- Width = 375
- End
- Begin VB.TextBox txtOctet
- Alignment = 2 'Center
- Appearance = 0 'Flat
- BorderStyle = 0 'None
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 240
- Index = 3
- Left = 975
- TabIndex = 3
- Text = "255"
- Top = 0
- Width = 375
- End
- Begin VB.TextBox txtOctet
- Alignment = 2 'Center
- Appearance = 0 'Flat
- BorderStyle = 0 'None
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 240
- Index = 4
- Left = 1455
- TabIndex = 4
- Text = "255"
- Top = 0
- Width = 375
- End
- Begin VB.Label lblDot
- Appearance = 0 'Flat
- AutoSize = -1 'True
- BackColor = &H80000005&
- Caption = "."
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 13.5
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 345
- Index = 1
- Left = 390
- TabIndex = 7
- Top = -90
- Width = 105
- End
- Begin VB.Label lblDot
- Appearance = 0 'Flat
- AutoSize = -1 'True
- BackColor = &H80000005&
- Caption = "."
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 13.5
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 345
- Index = 2
- Left = 870
- TabIndex = 6
- Top = -90
- Width = 105
- End
- Begin VB.Label lblDot
- Appearance = 0 'Flat
- AutoSize = -1 'True
- BackColor = &H80000005&
- Caption = "."
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 13.5
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 345
- Index = 3
- Left = 1350
- TabIndex = 5
- Top = -90
- Width = 105
- End
- End
- End
- Attribute VB_Name = "DJIp"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = False
- Option Explicit
- Option Base 1
- Enum ipBorder
- ccNone = 0
- ccFixedSingle = 1
- End Enum
- Enum AppearanceStyle
- ccFlat = 0
- cc3D = 1
- End Enum
- Private m_BackColor As OLE_COLOR
- Private m_ForeColor As OLE_COLOR
- Private m_ValidIp As Boolean
-
- 'Event Declarations:
- Event Click()
- Attribute Click.VB_Description = "Occurs when the user presses and then releases a mouse button over an object."
- Event Change()
- Attribute Change.VB_Description = "Occurs when the contents of a control have changed."
-
-
- Public Property Get BackColor() As OLE_COLOR
- Attribute BackColor.VB_Description = "Returns/sets the background color used to display text and graphics in an object."
- BackColor = m_BackColor
- End Property
-
- Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
- Dim intX As Integer
- Dim intC As Integer
-
- intC = txtOctet.Count
- For intX = 1 To intC
- txtOctet(intX).BackColor() = New_BackColor
- If intX < intC Then lblDot(intX).BackColor = New_BackColor
- Next
- m_BackColor = New_BackColor
- PropertyChanged "BackColor"
- End Property
-
- Public Property Get ForeColor() As OLE_COLOR
- Attribute ForeColor.VB_Description = "Returns/sets the foreground color used to display text and graphics in an object."
- ForeColor = m_ForeColor
- End Property
-
- Public Property Let ForeColor(ByVal New_ForeColor As OLE_COLOR)
- Dim intX As Integer
- Dim intC As Integer
-
- intC = txtOctet.Count
- For intX = 1 To intC
- txtOctet(intX).ForeColor() = New_ForeColor
- If intX < intC Then lblDot(intX).ForeColor = New_ForeColor
- Next
- m_ForeColor = New_ForeColor
- PropertyChanged "ForeColor"
- End Property
-
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=UserControl,UserControl,-1,Enabled
- Public Property Get Enabled() As Boolean
- Attribute Enabled.VB_Description = " Returns/sets a value that determines whether an object can respond to user-generated events."
- Enabled = UserControl.Enabled
- End Property
-
- Public Property Let Enabled(ByVal New_Enabled As Boolean)
- UserControl.Enabled() = New_Enabled
- PropertyChanged "Enabled"
- End Property
- Public Property Get ValidIp() As Boolean
- Attribute ValidIp.VB_Description = "Sets/returns state of valid ip checking. When true, will not allow an octet outside the valid range of 0-255"
- ValidIp = m_ValidIp
- End Property
-
- Public Property Let ValidIp(ByVal New_Valid As Boolean)
- m_ValidIp = New_Valid
- PropertyChanged "ValidIp"
- End Property
- Public Property Get Appearance() As AppearanceStyle
- Attribute Appearance.VB_Description = " Returns/sets whether or not an object is painted at run time with 3-D effects."
- Appearance = UserControl.Appearance
- End Property
-
- Public Property Let Appearance(ByVal New_Appearance As AppearanceStyle)
- UserControl.Appearance() = New_Appearance
- PropertyChanged "Appearance"
- End Property
-
-
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=UserControl,UserControl,-1,BorderStyle
- Public Property Get BorderStyle() As ipBorder
- Attribute BorderStyle.VB_Description = "Returns/sets the border style for an object."
- BorderStyle = UserControl.BorderStyle
- End Property
-
- Public Property Let BorderStyle(ByVal New_BorderStyle As ipBorder)
- UserControl.BorderStyle() = New_BorderStyle
- PropertyChanged "BorderStyle"
- End Property
-
- Public Sub Refresh()
- Attribute Refresh.VB_Description = "Forces a complete repaint of a object."
- Dim intX As Integer
- Dim intC As Integer
-
- intC = txtOctet.Count
- UserControl.Refresh
- For intX = 1 To intC
- txtOctet(intX).Refresh
- If intX < intC Then lblDot(intX).Refresh
- Next
- End Sub
-
- 'Load property values from storage
- Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
- With Me
- .BackColor = PropBag.ReadProperty("BackColor", &H80000005)
- .ForeColor = PropBag.ReadProperty("ForeColor", &H80000008)
- .ValidIp = PropBag.ReadProperty("ValidIp", True)
- End With
- UserControl.Enabled = PropBag.ReadProperty("Enabled", True)
- UserControl.BorderStyle = PropBag.ReadProperty("BorderStyle", ccFixedSingle)
- UserControl.Appearance = PropBag.ReadProperty("Appearance", ccFlat)
- End Sub
-
- 'Write property values to storage
- Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
-
- Call PropBag.WriteProperty("BackColor", txtOctet(1).BackColor, &H80000005)
- Call PropBag.WriteProperty("ForeColor", txtOctet(1).ForeColor, &H80000008)
- Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True)
- Call PropBag.WriteProperty("BorderStyle", UserControl.BorderStyle, ccFixedSingle)
- Call PropBag.WriteProperty("Appearance", UserControl.Appearance, ccFlat)
- Call PropBag.WriteProperty("ValidIp", m_ValidIp, True)
-
- End Sub
- Private Sub UserControl_InitProperties()
- m_ValidIp = True
- With Me
- .BackColor = &H80000005
- .ForeColor = Ambient.ForeColor
- End With
- End Sub
- Private Sub UserControl_Resize()
- Dim intX As Integer
-
- With UserControl
- intX = 50 * (.Appearance * .BorderStyle)
- If intX = 0 And .BorderStyle = 1 Then intX = 30
- End With
-
- With Frame1
- .Move 0, 0
- UserControl.Height = .Height + intX
- UserControl.Width = .Width + intX
- End With
- End Sub
-
- Private Sub txtOctet_Change(Index As Integer)
- Dim strTxt As String
-
- With txtOctet(Index)
- strTxt = .Text
- If Len(strTxt) > 3 Then strTxt = Left(strTxt, 3)
- strTxt = Str(CheckIp(Val(strTxt)))
- .Text = Trim(strTxt)
- End With
- RaiseEvent Change
- End Sub
-
- Private Function CheckIp(ByVal Octet As Integer) As Integer
- If m_ValidIp Then
- If Octet > 255 Then Octet = 255
- If Octet < 0 Then Octet = 0
- End If
- CheckIp = Octet
- End Function
-
- Private Sub txtOctet_GotFocus(Index As Integer)
- With txtOctet(Index)
- .SelStart = 0
- .SelLength = Len(.Text)
- End With
- End Sub
-
- Public Function GetIp() As String
- Attribute GetIp.VB_Description = "Returns the IP address "
- Dim intX As Integer
- Dim intC As Integer
- Dim strX As String
-
- intC = txtOctet.Count
- For intX = 1 To intC
- strX = strX & txtOctet(intX)
- If intX < intC Then
- strX = strX & "."
- End If
- Next
- GetIp = strX
- End Function
-
- Public Sub PutOctet(Octet As Integer, ByVal Address As Integer)
- Attribute PutOctet.VB_Description = "Sets value of specified octet."
- Dim intX As Integer
-
- If Octet < 1 Then Octet = 1
- intX = txtOctet.Count
- If Octet > intX Then Octet = intX
- txtOctet(Octet) = Address
- End Sub
-
- Private Sub txtOctet_KeyPress(Index As Integer, KeyAscii As Integer)
- Select Case KeyAscii
- Case vbKeyReturn
- KeyAscii = 0
- Call MoveFocus(Index, 1)
- End Select
- End Sub
-
- Private Sub MoveFocus(Index As Integer, Move As Integer)
- Index = Index + Move
- If Index > txtOctet.Count Then Index = 1
- If Index = 0 Then Index = txtOctet.Count
- txtOctet(Index).SetFocus
- End Sub
-
- Private Sub txtOctet_Click(Index As Integer)
- RaiseEvent Click
- End Sub
-
-